using FastNet.Core.Enums;
using FastNet.Core.Utilities;
using FastNet.Model.System;
using FastNet.System.IServices;

namespace FastNet.System.Services;

public class UserService : IUserService
{
    public async Task<ResponseContent> Login(LoginModel loginInfo, bool verificationCode = true)
    {
        var rsp = new ResponseContent();
        // IMemoryCache memoryCache = _context.GetService<IMemoryCache>();
        // string cacheCode = (memoryCache.Get(loginInfo.UUID) ?? "").ToString();
        // if (string.IsNullOrEmpty(cacheCode))
        // {
        //     return webResponse.Error("验证码已失效");
        // }
        // if (cacheCode.ToLower() != loginInfo.VerificationCode.ToLower())
        // {
        //     memoryCache.Remove(loginInfo.UUID);
        //     return webResponse.Error("验证码不正确");
        // }
        string token = JwtHelper.IssueJwt(new UserInfo()
        {
            User_Id = 1,
            UserName = "UndCover",
            Role_Id = 1
        });

        rsp.Data = new { token = token, userName = loginInfo.UserName };
        return rsp.OK(ResponseCode.LoginSuccess);
    }
}
